package org.suk.dp.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:秘书类 <br/>
 * @version V1.0  2017/6/20 21:05  by 石冬冬(dongdong.shi@ucarinc.com) - Heil Hitler
 */
public class Secretary {
    private List<Observer> observers = new ArrayList<Observer>();
    private String action;

    /**
     * 增加观察者
     * @param observer
     */
    public void attach(Observer observer){
        this.observers.add(observer);
    }

    /**
     * 减少观察者
     * @param observer
     */
    public void detach(Observer observer){
        this.observers.remove(observer);
    }

    /**
     * 通知所有相关观察者
     */
    public void notice(){
        for(Observer observer : this.observers){
            observer.update();
        }
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }
}
